#!/usr/bin/python3
#generate the .inp file for packmol
import sys

doc = """import "{alcohol}.lt"
import "MDVS_allatom_optimized_geometry.lt"
import "ions.lt"
write_once("Data Boundary")  {{
-0.1 140.1 xlo xhi
-0.1 30.1  ylo yhi
-0.1 30.1  zlo zhi
}}

water = new MDVS[3610]
alcohol = new {lt_alcohol}[{n_alcohol}]
{cation} = new {cation}[{n_cation}]
{anion} = new {anion}[{n_anion}]

write_once("In Init") {{
        units real
        atom_style      full
        bond_style      harmonic
        angle_style     harmonic
        dihedral_style  harmonic
        improper_style  harmonic
        variable cutoff equal 14.0 # Angstroms
        #pair_style      lj/cut/coul/cut  14.0  # for non-period sims
        pair_style      lj/cut/coul/long  14.0
        kspace_style    ewald 0.0001
        special_bonds lj 0.0 0.0 0.5 coul 0.0 0.0 1.0 angle yes dihedral yes
        boundary p p p
}}"""


alcohol = "hexan"
n_alcohol = 10
lt_alcohol = "126I"
cation = "Na"
n_cation = 10
anion = "Cl"
n_anion = 10



def make_system_lt(alcohol = alcohol,
           n_alcohol = n_alcohol,
           lt_alcohol = lt_alcohol,
           cation = cation,
           n_cation = n_cation,
           anion = anion,
           n_anion = n_anion):
    
    text = doc.format(alcohol = alcohol,
           n_alcohol = n_alcohol,
           lt_alcohol = lt_alcohol,
           cation = cation,
           n_cation = n_cation,
           anion = anion,
           n_anion = n_anion)
    
    #Debug
    print(text)

    return text

#make_system_lt()

if __name__ == '__main__':
    if len(sys.argv) != 9:
        print("""
        usage:
        ./make_system_lt.py hexan 10 126I Na 17 Cl 17 system
        """)
        exit -1
    file_content = make_system_lt(sys.argv[1],
                         sys.argv[2],
                         sys.argv[3],
                         sys.argv[4],
                         sys.argv[5],
                         sys.argv[6],
                         sys.argv[7])
    with open("{0}.lt".format(sys.argv[8]),'w') as f:
        f.write(file_content)
    

